package api

import (
	"api_getway/basic/config"
	__ "api_getway/basic/proto"
	"api_getway/handler/request"
	"github.com/gin-gonic/gin"
	"net/http"
)

func AddVideo(c *gin.Context) {
	var req request.AddVideoReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
		return
	}

	add, err := config.EpisodeClient.AddVideo(c, &__.AddVideoReq{
		Title:    req.Title,
		TypesId:  req.TypesId,
		CoverUrl: req.CoverUrl,
		PlayUrl:  req.PlayUrl,
	})
	if err != nil {
		c.JSON(http.StatusInternalServerError, gin.H{
			"code": 200,
			"msg":  "视频添加失败",
		})
		return
	}

	c.JSON(http.StatusOK, gin.H{
		"code": 200,
		"msg":  "该视频文件含有违禁词！",
		"id":   add.VideoId,
	})
}

func ShowVideo(c *gin.Context) {

	c.JSON(http.StatusOK, gin.H{
		"code": 200,
		"msg":  "用户不是会员！禁止访问该剧集！",
	})
}
